<?php
// Define path to application directory
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/application'));

// Define application environment
defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'development'));

defined('APPLICATION_ROOT') || define('APPLICATION_ROOT', realpath(dirname(__FILE__)));

// Ensure library/ is on include_path
set_include_path(
  implode(
    PATH_SEPARATOR, array(
      realpath(APPLICATION_PATH . '/library'), get_include_path(),
    )
  )
);

try{
	/** Zend_Application */
	require_once 'Zend/Application.php';
	
	defined('APPLICATION_INI') || define('APPLICATION_INI', '/configs/application.ini');
	
	// Create application, bootstrap, and run
	$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . APPLICATION_INI);
	$application->bootstrap()->run();
}
catch (Exception $exception) {
	echo"
    <html>
      <body>
        <center>Uma exceção ocorreu durante a inicialização do aplicativo.";
          if (defined('APPLICATION_ENV') && APPLICATION_ENV != 'production') {
            echo"
              <br /><br />{$exception->getMessage()}<br />
              <div align='left'>Stack Trace:
                <pre>{$exception->getTraceAsString()}</pre>
              </div>
            ";
          }
          echo"
        </center>
      </body>
    </html>
  ";
	exit(1);
}	